package org.example.service;

import org.example.entity.DeliveryAddress;
import org.example.mapper.IDeliveryAddressMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class DeliveryAddressService {

    @Autowired
    private IDeliveryAddressMapper deliveryAddressMapper;

    // 1. 根据用户编号查询所属送货地址
    public List<DeliveryAddress> listDeliveryAddressByUserId(String userId) {
        return deliveryAddressMapper.listDeliveryAddressByUserId(userId);
    }

    // 2. 根据送货地址编号查询送货地址
    public DeliveryAddress getDeliveryAddressById(Integer daId) {
        return deliveryAddressMapper.getDeliveryAddressById(daId);
    }

    // 3. 向送货地址表中添加一条记录
    public int saveDeliveryAddress(DeliveryAddress deliveryAddress) {
        return deliveryAddressMapper.saveDeliveryAddress(deliveryAddress);
    }

    // 4. 根据送货地址编号更新送货地址信息
    public int updateDeliveryAddress(DeliveryAddress deliveryAddress) {
        return deliveryAddressMapper.updateDeliveryAddress(deliveryAddress);
    }

    // 5. 根据送货地址编号删除一条记录
    public int removeDeliveryAddress(Integer daId) {
        return deliveryAddressMapper.removeDeliveryAddress(daId);
    }
} 